<div class="blazorise-codeblock">
<div class="html"><pre>

</pre></div>
<div class="csharp"><pre>
<span class="atSign">&#64;</span>code{
    <span class="keyword">private</span> <span class="keyword">bool</span> MyCustomFilter( FilterExample row )
    {
        <span class="keyword">return</span> _filterTracker.columnFilters <span class="keyword">is</span> <span class="keyword">null</span>
            ? <span class="keyword">true</span>
            : _filterTracker.columnFilters.All( x =&gt; EvaluateColumnFilter( x, row ) );
    }

    <span class="keyword">private</span> <span class="keyword">bool</span> EvaluateColumnFilter( ColumnFilter&lt;FilterExample&gt; columnFilter, FilterExample row )
    {
        Console.WriteLine( $<span class="string">&quot;Evaluating... {columnFilter.Column.Field}&quot;</span> );
        Console.WriteLine( $<span class="string">&quot;Filter to apply... {columnFilter.SelectedFilter}&quot;</span> );
        Console.WriteLine( $<span class="string">&quot;Search for... {columnFilter.SearchValue}&quot;</span> );


        <span class="comment">//You might need some reflection based or expression based getter to get the value of the corresponding field dynamically</span>
        <span class="comment">//Do whatever boolean logic you need to do here</span>
        <span class="comment">//We opted to use the DataGrid.Utils.FunctionCompiler.CreateValueGetter to create a dynamic getter for the field and using a simple comparer with the new GreaterThan and LessThan comparisons.</span>
        <span class="keyword">var</span> columnFieldGetter = DataGrid.Utils.FunctionCompiler.CreateValueGetter&lt;FilterExample&gt;( columnFilter.Column.Field );
        <span class="keyword">var</span> columnValue = columnFieldGetter( row );

        <span class="keyword">return</span> CompareFilterValues( columnValue.ToString(), columnFilter.SearchValue, columnFilter.SelectedFilter );

    }

    <span class="keyword">private</span> <span class="keyword">bool</span> CompareFilterValues( <span class="keyword">string</span> searchValue, <span class="keyword">string</span> compareTo, MyFilter filterMethod )
    {
        <span class="keyword">switch</span> (filterMethod)
        {
            <span class="keyword">case</span> MyFilter.StartsWith:
                <span class="keyword">return</span> searchValue.StartsWith( compareTo, StringComparison.OrdinalIgnoreCase );
            <span class="keyword">case</span> MyFilter.EndsWith:
                <span class="keyword">return</span> searchValue.EndsWith( compareTo, StringComparison.OrdinalIgnoreCase );
            <span class="keyword">case</span> MyFilter.Equals:
                <span class="keyword">return</span> searchValue.Equals( compareTo, StringComparison.OrdinalIgnoreCase );
            <span class="keyword">case</span> MyFilter.NotEquals:
                <span class="keyword">return</span> !searchValue.Equals( compareTo, StringComparison.OrdinalIgnoreCase );
            <span class="keyword">case</span> MyFilter.GreaterThan:
                <span class="keyword">if</span> (<span class="keyword">int</span>.TryParse( searchValue, <span class="keyword">out</span> <span class="keyword">var</span> parsedSearchValue ) &amp;&amp; <span class="keyword">int</span>.TryParse( compareTo, <span class="keyword">out</span> <span class="keyword">var</span> parsedCompareToValue ))
                {
                    <span class="keyword">return</span> parsedSearchValue &gt; parsedCompareToValue;
                }
                <span class="keyword">return</span> <span class="keyword">false</span>;
            <span class="keyword">case</span> MyFilter.LessThan:
                <span class="keyword">if</span> (<span class="keyword">int</span>.TryParse( searchValue, <span class="keyword">out</span> <span class="keyword">var</span> parsedSearchValueLessThan ) &amp;&amp; <span class="keyword">int</span>.TryParse( compareTo, <span class="keyword">out</span> <span class="keyword">var</span> parsedCompareToValueLessThan ))
                {
                    <span class="keyword">return</span> parsedSearchValueLessThan &lt; parsedCompareToValueLessThan;
                }
                <span class="keyword">return</span> <span class="keyword">false</span>;
            <span class="keyword">case</span> MyFilter.Contains:
            <span class="keyword">default</span>:
                <span class="keyword">return</span> searchValue.IndexOf( compareTo, StringComparison.OrdinalIgnoreCase ) &gt;= <span class="number">0</span>;
        }
    }
}
</pre></div>
</div>
